<h1>Listing tasks</h1>

<%= javascript_include_tag "prototype" %>

<% form_tag :action=>'exec_query' do%>
<table>
  <div id="criteries">
    <% @query.criteries_list.each do |criteria|%>
    <%= render :partial => 'layouts/filter/criteria',
               :locals => {:criteria=>criteria}%>
    <% end %>
  </div>
</table>

<%= columns_names_select @query %>

<%= submit_tag 'filter' %>

<%= observe_field 'tasks_columns',
                  :url=> {:action => 'add_criteria'},
                  :with=> "'column_name='+encodeURIComponent(value)"%>
<% end %>

<table>
  <tr>
    <th>Headline</th>
    <th>Description</th>
    <th>Submitter</th>
  </tr>

<% @tasks.each do |task| %>
  <tr>
    <td><%=h task.headline %></td>
    <td><%=h task.description %></td>
    <td><%=h task.submitter.name %></td>
    <td><%= link_to 'Show', task %></td>
    <td><%= link_to 'Edit', edit_task_path(task) %></td>
    <td><%= link_to 'Destroy', task, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New task', new_task_path %>
